# -*- coding: utf-8 -*-
# @Author  : haomh
# @Time    : 2025/10/28 17:19
# @Function:

import random

'''   
1.需求：有三个办公室，8位老师，8位老师随机分配到3个办公室
'''
# teachers = ['aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg', 'hh']
# offices = [[], [], []]
# for name in teachers:
#     num = random.randint(0, 2)
#     offices[num].append(name)
# i = 1
# for office in offices:
#     print(f'办公室{i}的人数是{len(office)}.老师分别是：', end='')
#     i += 1
#     for name in office:
#         print(name, end='...')
#     print('')


'''   
# 求100以内能被3整除的数，并将作为列表输出
'''

# list = []
# i = 1
# while i <= 100:
#     if i % 3 == 0:
#         list.append(i)
#     i += 1
# print(list)

'''   
3、列表[1,2,3,4,3,4,2,5,5,8,9,7],将此列表去重，得到一个唯一元素的列表  # 不允许用强制类型转化
'''

# list = [1, 2, 3, 4, 3, 4, 2, 5, 5, 8, 9, 7]
# list1 = []
# for i in list:
#     if i not in list1:
#         list1.append(i)
# print(list1)
'''
4、求斐波那契数列 1 1 2 3 5 8 13 ……    生成一个列表:12个元素
'''
# 初始化斐波那契数列，前两个元素为1和1
# list = [1, 1]
# # 生成后续元素直到列表有12个元素
# for i in range(2, 12):
#     next_num = list[i - 1] + list[i - 2]
#     list.append(next_num)
#
# print(f"12个元素的斐波那契数列: {list}")

'''
求100以内的质数/素数（只能被1和它本身整除
'''
# i = 2
# while (i < 101):
#     cnt = 0
#     for n in range(2, 101):
#         if i % n == 0:
#             cnt += 1
#             continue
#     if cnt == 1:
#         print(i, end=' ')
#     i += 1
'''
有一堆字符串“aabbbcddef”打印出不重复的字符串结果：cef #不允许用类型转化
'''
# str = 'aabbbcddef'
# result = ""
#
# for char in str:
#     count = 0
#     for c in str:
#         if c == char:
#             count += 1
#     if count == 1:
#         result += char
# print(result)

'''
7、有一堆字符串，“welocme to super&Test”，打印出superTest，#不能查字符的索引
'''
# str = 'welocme to super&Test'
#
# parts = str.split()
#
# result = parts[-1].replace("&", "")
# print(result)

'''
8、有一堆字符串，“welocme to super&Test”，打印出tseT&repus ot emcolew #不允许用reverse,和reversed,不允许用步长  除此之外用两种方法解答
'''
# s = "welocme to super&Test"
# reversed_list = []
# for char in s:
#     reversed_list.insert(0, char)
# reversed_str = ''.join(reversed_list)
# print(reversed_str)
'''
9、有一堆字符串，“aabbbcddef”，输出abcdef # 不允许用set  
'''
str = 'aabbbcddef'
str1 = ''
for i in str:
    if i not in str1:
        str1 += i
print(str1)
